#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
开放商户 - 商户主结算卡查询功能使用示例
"""

import os
import sys

# 添加项目根目录到Python路径，确保能够导入jlpay包
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from examples.base_example import BaseExample
from jlpay.services.openmerch.query.merch_master_sett_card_query_service import MerchMasterSettCardQueryService
from jlpay.model.openmerch.query.merch_master_sett_card_query import MerchMasterSettCardQueryRequest


class MerchMasterSettCardQueryExample(BaseExample):
    """商户主结算卡查询示例类"""
    
    def __init__(self):
        """初始化示例类"""
        super().__init__("examples.openmerch.query.master_sett_card")
        # 创建商户主结算卡查询服务实例
        self.merch_master_sett_card_query_service = MerchMasterSettCardQueryService(self.config)
    
    def build_merch_master_sett_card_query_request(self):
        """构建商户主结算卡查询请求"""
        request = MerchMasterSettCardQueryRequest()
        
        # 设置请求参数
        request.set_merch_no("849584358140108")
        
        return request
    
    def demo(self):
        """执行商户主结算卡查询示例"""
        self.logger.info("开始执行商户主结算卡查询示例")
        
        # 创建商户主结算卡查询请求
        request = self.build_merch_master_sett_card_query_request()
        
        # 发送请求
        self.send_request_and_handle_response(
            self.merch_master_sett_card_query_service.query_merch_master_sett_card,
            "商户主结算卡查询",
            request
        )
        
        self.logger.info("商户主结算卡查询示例执行完毕")


if __name__ == "__main__":
    example = MerchMasterSettCardQueryExample()
    example.logger.info("=" * 50)
    example.logger.info("===== 商户主结算卡查询示例 开始 =====")
    example.logger.info("=" * 50)
    
    example.demo()
    
    example.logger.info("=" * 50)
    example.logger.info("===== 商户主结算卡查询示例执行完毕 =====")
    example.logger.info("=" * 50) 